package tmp.etaoReload;

import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class Main {
	public static void main(String[] args) throws SQLException {
		Connection con=DAO.DbcpConnection.getConnection();
		Statement st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
		ResultSet rs=st.executeQuery("select * from etao_detail");
		while (rs.next()) {
			String imagepath=rs.getString("imagepath");
			if(!isImage(imagepath)){
				rs.updateInt("imagestatus", 0);
				rs.updateRow();
				System.out.println(imagepath);
			}
		}
	}

	private static boolean isImage(String imagepath) {
		if(imagepath==null){
			return true;
		}
		String [] tmp=imagepath.split("\\|");
		String basePath="V://";
		for(int i=0;i<tmp.length;i++){
			if(tmp[i].length()>3){
				File file=new File(basePath+tmp[i]);
				if(file.length()<1024){
					return false;
				}
			}
		}
		return true;
	}
}
